package com.zb.vo;

import com.zb.entity.ZjProduct;
import com.zb.entity.ZjSpare;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.util.Date;
import java.util.List;

/**
 * @Author WEN
 * @Date 2023/8/19 0019
 **/
@Data
@ApiModel("商品详情对象")
public class GoodesDetailVo {
    @ApiModelProperty(value = "主健ID")
    private Long id;

    @ApiModelProperty(value = "品牌名称")
    private String brand;

    @ApiModelProperty(value = "产品名称")
    private String name;

    @ApiModelProperty(value = "产品型号")
    private String model;

    @ApiModelProperty(value = "产品编码")
    private String code;

    @ApiModelProperty(value = "产品货号")
    private String itemNumber;

    @ApiModelProperty(value = "商品单位")
    private String unit;

    @ApiModelProperty(value = "商品分类名称")
    private String type;

    @ApiModelProperty(value = "产品来源：1-售后系统创建，2-excel导入，3-金蝶ERP导入，4-第三方接口创建")
    private Integer source;

    @ApiModelProperty(value = "是否启用登记关联：0-否，1-是")
    private Boolean enabledRegister;

    @ApiModelProperty(value = "商品状态: false-启用，true-禁用")
    private Boolean status;

    @ApiModelProperty(value = "创建时间")
    private Date createTime;

    @ApiModelProperty(value = "更新时间")
    private Date updateTime;

    @ApiModelProperty(value = "商品图片")
    private List<String> images;


    public static GoodesDetailVo beanToVo(ZjProduct product, List<String> images) {
        GoodesDetailVo vo = new GoodesDetailVo();
        BeanUtils.copyProperties(product, vo);
        vo.setStatus(product.getDisabled());
        vo.setCreateTime(product.getGmtCreate());
        vo.setUpdateTime(product.getGmtUpdate());
        vo.setImages(images);
        return vo;
    }

    public static GoodesDetailVo beanToVo(ZjSpare spare, List<String> images) {
        GoodesDetailVo vo = new GoodesDetailVo();
        BeanUtils.copyProperties(spare, vo);
        vo.setStatus(spare.getDisabled());
        vo.setCreateTime(spare.getGmtCreate());
        vo.setUpdateTime(spare.getGmtUpdate());
        vo.setImages(images);
        return vo;
    }

}
